
$(document).ready( function() {

  var user_agents = [{group: 'win7', ua: 'firefox_4'},
                     {group: 'win7', ua: 'ie_9'},  
                     {group: 'win7', ua: 'chrome_10'},
                     {group: 'win7', ua: 'safari_5'},
                     {group: 'win7', ua: 'opera_11'},
                     {group: 'win7uia', ua:'ie_9'},    
                     {group: 'osx106', ua: 'safari_5'},
                     {group: 'osx106', ua: 'firefox_4'},
                     {group: 'osx106', ua: 'chrome_10'},
                     {group: 'osx106', ua: 'opera_11'},
                     {group: 'unix', ua: 'firefox_4'},
                     {group: 'sr', ua:'jaws_12_ff_4'},
                     {group: 'sr', ua:'jaws_12_ie_9'},
                     {group: 'sr', ua:'jaws_12_chrome_10'},
                     {group: 'sr', ua:'nvda_ff_4'},
                     {group: 'sr', ua:'nvda_ie_9'},
                     {group: 'sr', ua:'nvda_chrome_10'},
                     {group: 'sr', ua:'nvda_safari_5'},
                     {group: 'sr', ua:'windoweyes_71'},
                     {group: 'sr', ua:'voiceover'}
                    ];

  var html = "";
  
  //index 
  html += "<ul>";  
  	
  for (var u=0;  u < user_agents.length; u++) {
  		
  		
     html += "<li><a href='user_agent.html#" + user_agents[u].group + "_" + user_agents[u].ua + "'>" + ARIA_TEST_CONSTANTS.GROUP[user_agents[u].group] + ": " + ARIA_TEST_CONSTANTS.USER_AGENT[user_agents[u].ua] + "</a><br>";

  		    		}// end for
  		
  html += "</ul>";
  
  //table
  for (var ua = 0; ua < user_agents.length; ua++ ) {
    html += "<h2><a name='" + user_agents[ua].group + "_" + user_agents[ua].ua + "'>" + ARIA_TEST_CONSTANTS.GROUP[user_agents[ua].group] + ": " + ARIA_TEST_CONSTANTS.USER_AGENT[user_agents[ua].ua] + "</a></h2>";
    html += "<table class='useragents'>";
    html += "  <thead>";
    html += "    <th id='test'>Test<br/>ID</th>";
    html += "    <th id='desc'>Description</th>";
    html += "    <th id='stat'>States</th>";
    html += "    <th id='prop'>Properties</th>";
    html += "    <th id='mr'>Mapping Results</th>";
    html += "    <th id='anr'>Accessible Name Results</th>";
    html += "    <th id='cm'>Comments</th>";
    html += "  </thead>";
    
    html += "  <tbody>";
    for(var i = 0; i < aria_test_results.results.length; i++ ) {
  
      var id = aria_test_results.results[i].id.split("_");    
      var group = parseInt(id[1],10);
      var num   = parseInt(id[2],10);
      var test_id = "test" + group + "_" + num; 
    
      var os_group = aria_test_results.results[i].results[user_agents[ua].group];

      for(var j=0; j < os_group.length; j++ ) {
      
        if( os_group[j].name == user_agents[ua].ua ) {
           
           
           html += "    <tr>";
           html += "      <th id='" + test_id + "'>" + group + "." + num + "</th>";
           html += "      <td headers='" + test_id + " desc' class='desc'>";
           html += "        <a href='" + aria_test_results.results[i].path + aria_test_results.results[i].file + "'>"+ aria_test_results.results[i].title + "</a>";
           html += "      </td>";
           // States
           html += "      <td headers='" + test_id + " stat'>";
           html += "        <ul>";
           var states = aria_test_results.results[i].states;
           for(var k=0; k < states.length; k++) {
               html += "        <li>" + states[k] +  "</li>";  
           } // endfor    
           html += "         </ul>";
           html += "       </td>";

           // Properties
           html += "      <td headers='" + test_id + " prop'>";
           html += "        <ul>";
           var properties = aria_test_results.results[i].properties;
           for(var l=0; l < properties.length; l++) {
               html += "        <li>" + properties[l] +  "</li>";  
           } // endfor    
           html += "         </ul>";
           html += "       </td>";

           
           
           html += "      <td>" + ARIA_TEST_CONSTANTS.RESULT[os_group[j]['result']] + "</td>";
           html += "      <td>" + ARIA_TEST_CONSTANTS.RESULT[os_group[j]['accessible_name']] + "</td>";
           html += "      <td>" + os_group[j]['comment'] + "</td>";
           html += "    </tr>";
        } // endif
      
      } // endfor
      html += "  </tbody>";
    

    } // endfor
    html += "</table>";
    html += "<a href='user_agent.html#top'>Back to top</a>";
    html += "<br><br>";
    
    
    
 } // endfor   

  $('div#content').append(html);

} // end ready function
); // end ready event

